package com.opensky.qatest.ui.component;

import org.openqa.selenium.By;

import com.opensky.qatest.ui.component.common.AbstractJoinModal;
import com.opensky.qatest.util.selenium.WebDriverWrapper;

/*
 * Join modal on Category page
 *
 * @author: Aliakse_Khursevich (hursevich@gmail.com)
 * @version: 1.1
 * 
 */
public class CategoryPageJoinModal extends AbstractJoinModal implements IComponent {

    // ************************ Locators ************************

    private static final String CATEGORY_JOIN_MODAL = "//div[@id='ui-tooltip-modal']";

    private static final String MESSAGE_CONTAINER = "//div[@id='join-modal']//div[@class='words']";

    private static final String MESSAGE = "Shop with our expert curators";

    public CategoryPageJoinModal(WebDriverWrapper driver) {
	super(driver);
    }

    // ************************ Validations **************************

    public boolean isMessagePresent() {
	return driver.waitAndVerifyElementWithTextPresent("MESSAGE_CONTAINER", By.xpath(MESSAGE_CONTAINER), MESSAGE);
    }

    @Override
    public boolean isComponentLoaded() {
	driver.pause(5);
	return driver.waitAndVerifyElementPresent("CATEGORY_JOIN_MODAL", By.xpath(CATEGORY_JOIN_MODAL));
    }

    // ************************ GET/SET methods **************************

    @Override
    public String getName() {
	return "Category page join modal";
    }
}
